package com.ruoyi.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.entity.DTO.LegalAidLawyerDTO;
import com.ruoyi.entity.Evaluate;
import com.ruoyi.entity.vo.LegalAidLawyerVO;
import com.ruoyi.service.EvaluateService;
import com.ruoyi.service.ILegalAidLawyerWxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 律师信息Controller
 * 
 * @author ruoyi
 * @date 2023-08-09
 */
@RestController
@RequestMapping("/wx/lawyer")
@Slf4j
@Api(tags = "律师管理")
public class LegalAidLawyerWxController extends BaseController
{
    @Autowired
    private ILegalAidLawyerWxService legalAidLawyerService;

    @Autowired
    private EvaluateService evaluateService;

    @GetMapping("/list")
    @ApiOperation("查询律师信息列表")
    public TableDataInfo list(LegalAidLawyerDTO legalAidLawyerDTO) {
        List<LegalAidLawyerVO> list = legalAidLawyerService.selectLegalAidLawyerList(legalAidLawyerDTO);
        return getDataTable(list);

    }


    /**
     * 根据id获取律师信息详细信息
     */
    @GetMapping("/getInfo")
    public AjaxResult getInfo(@RequestParam("id") Long id)
    {
        log.info("根据id查询律师信息：{}",id);
        LegalAidLawyerVO legalAidLawyerVO = legalAidLawyerService.selectLawyerWithUserById(id);
        return success(legalAidLawyerVO);
    }

    /**
     * 查看对律师的评论列表
     * @param id
     * @return
     */
    @GetMapping("/getEvaluate")
    public  AjaxResult getEvaluate(@RequestParam("id")Long id){
        log.info("id",id);
        List<Evaluate>  evaluateList =  evaluateService.getEvaluateByEvaluateId(id);
        return success(evaluateList);
    }

}
